<!--
 ~ This program is part of the OpenLMIS logistics management information system platform software.
 ~ Copyright © 2013 VillageReach
 ~
 ~  This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
 ~
 ~  This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more details.
 ~  You should have received a copy of the GNU Affero General Public License along with this program.  If not, see http://www.gnu.org/licenses.  For additional information contact info@OpenLMIS.org.
 -->
<ng-include src="'/public/pages/logistics/distribution/partials/record-facility-data.html'"></ng-include>
<div class="clearfix facility-container">
  <ng-include src="'/public/pages/logistics/distribution/partials/record-facility-menu.html'"></ng-include>

  <div class="facility-info" ng-init="facilityData = distribution.facilityDistributions[selectedFacility]">
    <div class="facility-visit-container">
      <h3>
        <span id="visitInformationLabel" openlmis-message="label.visit.information"></span>
      </h3>

      <form class="form-group" auto-save="distribution" object-store="distributions"
            disable-form="{{facilityData.isDisabled()}}">
        <div class="form-row clearfix">
          <label id="wasFacilityVisited"
                 openlmis-message="label.was.facility.visited|facilityData.facilityName|distribution.period.name"></label>

          <div>
            <input id="facilityVisitedYes" type="radio" ng-model="facilityData.facilityVisit.visited"
                   ng-value="true">
            <label for="facilityVisitedYes" class="radio-label" openlmis-message="label.yes"></label>
            <input id="facilityVisitedNo" type="radio" ng-model="facilityData.facilityVisit.visited"
                   ng-value="false">
            <label for="facilityVisitedNo" class="radio-label" openlmis-message="label.no"></label>
          </div>
        </div>

        <div ng-show="facilityData.facilityVisit.visited === true">
          <div class="form-row clearfix">
            <span id="visitDateContainer">
              <label for="visitDate" openlmis-message="label.visit.date"></label>
              <input id="visitDate" type="text" ui-date="{dateFormat: 'dd/mm/yy', changeYear: true, defaultDate: distribution.period.stringStartDate, beforeShowDay: beforeDatepickerShowDay}"
                     ui-date-format="yy-mm-dd"
                     readonly ng-model="facilityData.facilityVisit.visitDate"
                     ng-class="{'required-error': !facilityData.facilityVisit.visitDate}"/>
            </span>

            <span id="vehicleIdContainer">
              <label for="vehicleId" openlmis-message="label.vehicle.id"></label>
              <input id="vehicleId" maxlength="20" type="text" ng-model="facilityData.facilityVisit.vehicleId"/>
            </span>
          </div>

          <div class="form-row clearfix">
            <label openlmis-message="label.observations"></label>
            <textarea id="observations" maxlength="1000"
                      ng-model="facilityData.facilityVisit.observations"></textarea>
          </div>
          <div class="signatures clearfix">
            <div class="details-container">
              <span openlmis-message="label.verified.by" class="list-header-container list-header"></span>

              <div>
                <label openlmis-message="label.name" for="verifiedByName"></label>
                <input type="text" maxlength="50"
                       ng-model="facilityData.facilityVisit.verifiedBy.name"
                       id="verifiedByName"
                       ng-class="{'required-error': !facilityData.facilityVisit.verifiedBy.name}"/>
                <label openlmis-message="label.title" for="verifiedByTitle"></label>
                <input type="text" maxlength="50"
                       ng-model="facilityData.facilityVisit.verifiedBy.title"
                       id="verifiedByTitle"
                       ng-class="{'required-error': !facilityData.facilityVisit.verifiedBy.title}"/>
              </div>
            </div>

            <div class="details-container">
                            <span openlmis-message="label.confirmed.by"
                                  class="list-header-container list-header"></span>

              <div>
                <label openlmis-message="label.name" for="confirmedByName"></label>
                <input type="text" maxlength="50"
                       ng-model="facilityData.facilityVisit.confirmedBy.name"
                       id="confirmedByName"
                       ng-class="{'required-error': !facilityData.facilityVisit.confirmedBy.name}"/>
                <label openlmis-message="label.title" for="confirmedByTitle"></label>
                <input type="text" maxlength="50"
                       ng-model="facilityData.facilityVisit.confirmedBy.title"
                       id="confirmedByTitle"
                       ng-class="{'required-error': !facilityData.facilityVisit.confirmedBy.title}"/>
              </div>
            </div>
          </div>
        </div>

        <div class="form-row" ng-show="facilityData.facilityVisit.visited === false">
          <div class="form-group not-visit-reason-form">
            <div class="form-row clearfix">
              <label class="radio-label" openlmis-message="label.reason.for.no.visit"></label>
            </div>

            <div class="form-row clearfix">
              <input id="badWeather{{ $index }}" type="radio"
                     ng-model="facilityData.facilityVisit.reasonForNotVisiting"
                     value="{{reasons.badWeather}}"/>
              <label class="radio-label" for="badWeather{{ $index }}"
                     openlmis-message="label.bad.weather"></label>
            </div>
            <div class="form-row clearfix">
              <input id="noTransport{{ $index }}" type="radio"
                     ng-model="facilityData.facilityVisit.reasonForNotVisiting"
                     value="{{reasons.noTransport}}"/>
              <label class="radio-label" for="noTransport{{ $index }}"
                     openlmis-message="label.no.transport"></label>
            </div>
            <div class="form-row clearfix">
              <input id="facilityClosed{{ $index }}" type="radio"
                     ng-model="facilityData.facilityVisit.reasonForNotVisiting"
                     value="{{reasons.facilityClosed}}"/>
              <label class="radio-label" for="facilityClosed{{ $index }}"
                     openlmis-message="label.facility.closed"></label>
            </div>
            <div class="form-row clearfix">
              <input id="refrigeratorsNotWorking{{ $index }}" type="radio"
                     ng-model="facilityData.facilityVisit.reasonForNotVisiting"
                     value="{{reasons.refrigeratorsNotWorking}}"/>
              <label class="radio-label" for="refrigeratorsNotWorking{{ $index }}"
                     openlmis-message="label.refrigerators.not.working"></label>
            </div>
            <div class="form-row clearfix">
              <input id="noRefrigerators{{ $index }}" type="radio"
                     ng-model="facilityData.facilityVisit.reasonForNotVisiting"
                     value="{{reasons.noRefrigerators}}"/>
              <label class="radio-label" for="noRefrigerators{{ $index }}"
                     openlmis-message="label.no.refrigerators"></label>
           </div>
            <div class="form-row clearfix">
              <input id="unavailableFunds{{ $index }}" type="radio"
                     ng-model="facilityData.facilityVisit.reasonForNotVisiting"
                     value="{{reasons.unavailableFuelFunds}}"/>
              <label class="radio-label" for="unavailableFuelFunds{{ $index }}"
                     openlmis-message="label.unavailable.funds.fuel"></label>
            </div>
            <div class="form-row clearfix">
             <input id="unavailablePerDiemFunds{{ $index }}" type="radio"
                     ng-model="facilityData.facilityVisit.reasonForNotVisiting"
                     value="{{reasons.unavailablePerDiemFunds}}"/>
             <label class="radio-label" for="unavailablePerDiemFunds{{ $index }}"
                     openlmis-message="label.unavailable.funds.perdiem"></label>
            </div>
            <div class="form-row clearfix">
              <input id="notPartOfProgram{{ $index }}" type="radio"
                     ng-model="facilityData.facilityVisit.reasonForNotVisiting"
                     value="{{reasons.notPartOfProgram}}"/>
              <label class="radio-label" for="notPartOfProgram{{ $index }}"
                     openlmis-message="label.not.part.of.program"></label>
            </div>
            <div class="form-row clearfix">
              <input id="other{{ $index }}" type="radio"
                     ng-model="facilityData.facilityVisit.reasonForNotVisiting" value="{{reasons.other}}"
                     ng-click="facilityData.facilityVisit.otherReasonDescription = (facilityData.facilityVisit.reasonForNotVisiting === reasons.other ? facilityData.facilityVisit.otherReasonDescription : undefined)"/>
              <label class="radio-label" for="other{{ $index }}" openlmis-message="label.other"></label>
            </div>
            <div class="form-row clearfix">
              <textarea ng-model="facilityData.facilityVisit.otherReasonDescription"
                        id="otherTextBox"
                        ng-show="facilityData.facilityVisit.reasonForNotVisiting === reasons.other"
                        maxlength="255"
                        ng-class="{'required-error': !facilityData.facilityVisit.otherReasonDescription}">
              </textarea>
            </div>
          </div>
        </div>
      </form>
    </div>
  </div>
</div>
